const { sh } = require('tasksfile');
const dedent = require('dedent');

/** @type {TaskRegister} */
module.exports = {
  name: 'appDeploy',
  description: '打包工程应用',
  async register(options) {
    const { mode } = options;
    const VITE_APP_ENV = process.env.MODE || mode || 'production';

    await sh(`deploy publish --env=${VITE_APP_ENV} --unprompt`, {
      async: true,
      nopipe: true,
    });
  },
  options: {
    doc: '打包文档',
    mode: '打包的服务：development、testb、testc、testd、teste、uat、production',
  },
  examples: dedent`
    gtask appDeploy
    gtask appDeploy --mode=development
  `,
};
